/**
 *      __            ____
 *     / /__ _  __   / __/                      __  
 *    / //_/(_)/ /_ / /  ___   ____ ___  __ __ / /_ 
 *   / ,<  / // __/_\ \ / _ \ / __// _ \/ // // __/ 
 *  /_/|_|/_/ \__//___// .__//_/   \___/\_,_/ \__/  
 *                    /_/   github.com/KitSprout    
 * 
 *  @file    main.c
 *  @author  KitSprout
 *  @date    03-Jun-2018
 *  @brief   
 * 
 */

/* Includes --------------------------------------------------------------------------------*/
#include "drivers\stm32f4_system.h"
#include "drivers\stm32f4_tim_pwm.h"
#include "stm32f4xx_bsp.h"

/** @addtogroup STM32_Program
 *  @{
 */

/* Define ----------------------------------------------------------------------------------*/
/* Macro -----------------------------------------------------------------------------------*/
/* Typedef ---------------------------------------------------------------------------------*/
/* Variables -------------------------------------------------------------------------------*/
/* Prototypes ------------------------------------------------------------------------------*/
/* Functions -------------------------------------------------------------------------------*/

int main( void )
{
  uint8_t state = 0;
  uint32_t i = PWM_MIN;

  bsp_gpio_init();
  bsp_tim_pwm_init();

  while(1) {
    i = (state) ? (i - 1) : (i + 1);
    if (i == PWM_MAX){ state = 1; }
    if (i == PWM_MIN){ state = 0; }

    TIM_PWM_SetDuty(1, i);
    TIM_PWM_SetDuty(2, i);
    TIM_PWM_SetDuty(3, i);
    TIM_PWM_SetDuty(4, i);

    LED_G_Toggle();
    delay_ms(5);
  }
}

/*************************************** END OF FILE ****************************************/
